package com.wwmz.open.closed.impl;

/**
 * 一期：获取商品的价格
 * 二期：商品打折，在不改动一期代码的情况下，新建类做扩展，满足开闭原则
 * 对扩展开放，对修改关闭
 * Created by wumz on 2020/9/13 11:28
 */
public class Test {

    public static void main(String[] args) {
        IProduct iProduct = new JavaDiscountProduct(1, "洗面奶", 2280D);
        JavaDiscountProduct javaDiscountProduct = (JavaDiscountProduct) iProduct;
        System.out.println("商品ID：" + javaDiscountProduct.getId() +
                "\n商品名称：《" +  javaDiscountProduct.getName() + "》" +
                "\n原价：" + javaDiscountProduct.getPrice() +
                "\n售价：" + javaDiscountProduct.getDiscountPrice(0.6D));
    }
}
